{extend name="public/nav" /}
{block name="title"} 档案管理系统 {/block}

{block name="content"}
<style>
    html,body{
        height: 100%;
    }
    input{
        border: none;
    }
    .layui-input-block{
        margin-left: 0px;
    }
    .layui-form-select dl dd.layui-this {
        background-color: #1296db;
        color: #fff;
    }
    #img img{
        width: 120px;
        height: 120px;
        border-radius: 250px;
    }
    .layui-btn-color{
        background-color: transparent;
        color: #2D93CA;
        font-weight: bold;
        display: block;
        width: 100%;
        border: 1px solid #1296db;
    }
    .upload-img{
        width: 30.5%;
        padding: 1%;
        border: 1px solid #ccc;
        text-align: center;
        float: left;
    }
    .upload-img img{
        height: 60px;
        margin-bottom: 5px;
    }
</style>
<div class="site-content" style="background-color: #cccccc;">
    <div class="site-h1">
        <i class="layui-icon layui-icon-left" onclick="window.location.href='/'"></i>区域添加
    </div>
    <div class="layui-container">
        <div class="site-text" style="margin-top: 30px;">
            <form class="layui-form" method="post">

                <div class="layui-form-item">
                    <div>区域名称</div>
                    <div class="layui-input-block">
                        <input type="text" name="region_name" required lay-verify="required" placeholder="" autocomplete="off"
                            class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div>区域简介</div>
                    <div class="layui-input-block">
                        <textarea name="region_desc" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div>指定角色</div>
                    <div class="layui-input-block">
                        <select name="group_id">
                            {foreach $group as $g}
                            <option value="{$g.id}">{$g.group_name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div>开启状态</div>
                    <div class="layui-input-block">
                        <select name="region_status">
                            <option value="0">开启</option>
                            <option value="1">关闭</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-color" lay-submit lay-filter="add">保存</button>
                    </div>
                </div>
            </form>

            <script type="text/javascript">
                layui.use(['form', 'upload', 'jquery'], function () {
                    var form = layui.form, upload = layui.upload, layer = layui.layer, $ = layui.jquery;
                    //提交
                    form.on('submit(add)', function (data) {
                        $.post('{:url("index/region/add")}', data.field, function (res) {
                            if (res.code == 0) {
                                layer.msg('保存成功', { icon: 6, time: 1000 }, function () {
                                    window.location.href = '{:url("index/region/index")}';
                                })
                            } else {
                                layer.msg('保存失败');
                            }
                        }, 'json');
                        return false;
                    });
                })
            </script>
        </div>
    </div>
</div>
{/block}